package ai.plantdata.Structural.mode.FlyweightPattern.test;

import ai.plantdata.Structural.mode.FlyweightPattern.factorys.ShapeFactory;
import ai.plantdata.Structural.mode.FlyweightPattern.interfaces.impl.Circle;

/**
 * @Author: WangHui
 * @Date: 2020/12/21 16:46
 * @Description:
 */
public class FlyweightPatternDemo {
    private static final String[] COLORS = {"Red","Green","Blue","White","Black"};

    public static void main(String[] args){
        for (int i = 0; i < 20; i++) {
            Circle circle = (Circle) ShapeFactory.getCircle(getRandowcolor());
            circle.setX(getRandomX());
            circle.setY(getRandomY());
            circle.setRadius(100);
            circle.draw();
        }
    }

    private static String getRandowcolor(){
        return COLORS[(int)(Math.random()* COLORS.length)];
    }

    private static int getRandomX(){
        return (int)(Math.random()*100);
    }
    private static int getRandomY(){
        return (int)(Math.random()*100);
    }
}
